# coding=utf-8
from sklearn.decomposition import PCA
from pandas.core.frame import DataFrame
import pandas as pd
import numpy as np

l = []
with open('test.csv', 'r') as fd:
    line = fd.readline()
    while line:
        if line == "":
            continue

        line = line.strip()
        word = line.split(",")
        l.append(word)
        line = fd.readline()

data_l = DataFrame(l)
print(data_l)
dataMat = np.array(data_l)

pca_sk = PCA(n_components=2)
newMat = pca_sk.fit_transform(dataMat)

data1 = DataFrame(newMat)
data1.to_csv('test_PCA.csv', index=False, header=False)